package com.google.code.jtasks.bugzilla.config;

import com.google.code.jtasks.bugzilla.fields.BugzillaStandardField;

/**
 * Encapsulates information about a field used by a Bugzilla server.
 */
public final class BugzillaRepositoryField
{
	private final BugzillaStandardField fieldConstant;
	private final String fieldName;

	/**
	 * Constructs a new {@link BugzillaRepositoryField} instance.
	 * 
	 * @param fieldConstant
	 *            the {@link BugzillaStandardField} constant for this {@link BugzillaRepositoryField} or
	 *            <code>null</code> if this is a custom/non-standard field
	 * @param fieldName
	 *            the unique name of this field (for this Bugzilla server)
	 */
	public BugzillaRepositoryField(BugzillaStandardField fieldConstant, String fieldName)
	{
		if (fieldName == null || fieldName.trim().length() == 0)
			throw new IllegalArgumentException(String.format("Invalid field name '%s'.", fieldName));

		this.fieldConstant = fieldConstant;
		this.fieldName = fieldName;
	}
}
